#Created by Luxh on 2014/ 6 / 30

xlsx = require('node-xlsx');
ObjectId = require('mongoose').Types.ObjectId
fsdb = require('../config').fsdb.db

exports.parse_xlsx = (xlsx_path)->
  result = {}
  obj = xlsx.parse(xlsx_path);
  if obj
    result.maxCol = obj.worksheets[0].maxCol;
    result.maxRow = obj.worksheets[0].maxRow;
    result.data = obj.worksheets[0].data;
  return result



exports.delete_by_file_id = (file_id,cb) ->
  fsdb.collection('fs.chunks').remove {"files_id":new ObjectId(file_id)},(err)->
    if err
      cb(err)
    else
      cb(null)